﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace StarForce
{
    public class ScanComponents : GameFrameworkComponent
    {
        public string ScanResult;

        private AndroidJavaClass m_jc;
        
        void Start()
        {
            ScanResult = string.Empty;
            m_jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        }

        /// <summary>
        /// 调用安卓扫码功能 --- 内置封装 - 
        /// </summary>
        public void UseScan()
        {
            ScanResult = string.Empty;
            AndroidJavaObject jo = m_jc.GetStatic<AndroidJavaObject>("MainActivity");
            
            jo.Call("UnityUseScan");
        }

        /// <summary>
        /// 接受回调
        /// </summary>
        public void GetScanResult(string res)
        {
            Log.Info("接受到扫码的内容：{0}",res);
            ScanResult = res;
        }
    }
}

